import Vue from 'vue'
import VueRouter from 'vue-router'
//引入home，user
import HomePage from '../views/HomePage.vue'
import UserPage from '../views/UserPage.vue'
import MainPage from '../views/MainPage.vue'

import PageOne from '../views/PageOne.vue'
import PageTwo from '../views/PageTwo.vue'
import MallPage from '../views/MallPage.vue'
// 使用 Vue Router
Vue.use(VueRouter)
// 1.创建路由组件
// 2.配置路由映射
const routes = [
    {
        path: '/',
        component: MainPage,
        //重定向到home
        redirect: '/home',//子路由
        children: [
            {
                path: 'home',
                name: 'home',
                component: HomePage
            },
            {
                path: 'user',
                name: 'user',
                component: UserPage
            },
            {
                path: 'mall',
                name: 'mall',
                component: MallPage
            },
            {
                path: 'page1',
                name: 'page1',
                component: PageOne
            },
            {
                path: 'page2',
                name: 'page2',
                component: PageTwo
            }
        ]
    }
]
const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
})
export default router